from django.template import Template
from google.appengine.api import users
from django.shortcuts import render_to_response as rtr

from cv.forms import PersonalForm
from classes import DivErrorList

def mk_cv_menu(data, rurl, href, text):
	hrclass = ""
	if rurl == href:
		hrclass="active"
	data.append({'href': href, 'class': hrclass, 'text': text})

def init_data(rurl):
	data = []
	mk_cv_menu(data, rurl, "/create/personal/", "Personal Information")
	mk_cv_menu(data, rurl, "/create/employment/", "Desired Employment / Occupational Field")
	mk_cv_menu(data, rurl, "/create/work-experience/", "Work Experience")
	mk_cv_menu(data, rurl, "/create/education/", "Education and Training")
	mk_cv_menu(data, rurl, "/create/languages/", "Language(s)")
	mk_cv_menu(data, rurl, "/create/skills/", "Personal Skills and Competences")
	mk_cv_menu(data, rurl, "/create/additional/", "Additional Information and Annexes")
	mk_cv_menu(data, rurl, "/create/save/", "Save your CV")
	data = { 'cv_menu':	data}
	return data

def personal(request):
	data = init_data("/create/personal/")
	data['form_title'] = "Personal Information"
	if request.method == 'POST':
		personal_form = PersonalForm(request.POST, error_class=DivErrorList)
		if personal_form.is_valid():
			pdata = personal_form.cleaned_data
			data['form_title'] = "coll"
	else:
		personal_form = PersonalForm()
	data['personal_form'] = personal_form
	return rtr("create/index.html", data)

#def personal(request):
#	data = init_data(request.path)
#	return rtr("create/index.html", data)

